!pip install ultralytics torch torchvision opencv-python pillow boto3
Requirement already satisfied: ultralytics in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (8.3.96) Requirement already satisfied: torch in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (2.6.0) Requirement already satisfied: torchvision in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (0.21.0) Requirement already satisfied: opencv-python in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (4.11.0.86) Requirement already satisfied: pillow in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (11.1.0) Requirement already satisfied: boto3 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (1.37.7) Requirement already satisfied: numpy<=2.1.1,>=1.23.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (1.26.4) Requirement already satisfied: matplotlib>=3.3.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (3.10.0) Requirement already satisfied: pyyaml>=5.3.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (6.0.2) Requirement already satisfied: requests>=2.23.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (2.32.3) Requirement already satisfied: scipy>=1.4.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (1.15.1) Requirement already satisfied: tqdm>=4.64.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (4.67.1) Requirement already satisfied: psutil in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (6.1.1) Requirement already satisfied: py-cpuinfo in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (9.0.0) Requirement already satisfied: pandas>=1.1.4 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (1.5.3) Requirement already satisfied: seaborn>=0.11.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (0.13.2) Requirement already satisfied: ultralytics-thop>=2.0.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from ultralytics) (2.0.14) Requirement already satisfied: filelock in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (3.17.0) Requirement already satisfied: typing-extensions>=4.10.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (4.12.2) Requirement already satisfied: networkx in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (3.4) Requirement already satisfied: jinja2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (3.1.5) Requirement already satisfied: fsspec in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (2025.2.0) Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.4.127 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.127) Requirement already satisfied: nvidia-cuda-runtime-cu12==12.4.127 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.127) Requirement already satisfied: nvidia-cuda-cupti-cu12==12.4.127 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.127) Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (9.1.0.70) Requirement already satisfied: nvidia-cublas-cu12==12.4.5.8 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.5.8) Requirement already satisfied: nvidia-cufft-cu12==11.2.1.3 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (11.2.1.3) Requirement already satisfied: nvidia-curand-cu12==10.3.5.147 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (10.3.5.147) Requirement already satisfied: nvidia-cusolver-cu12==11.6.1.9 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (11.6.1.9) Requirement already satisfied: nvidia-cusparse-cu12==12.3.1.170 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.3.1.170) Requirement already satisfied: nvidia-cusparselt-cu12==0.6.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (0.6.2) Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (2.21.5) Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.127) Requirement already satisfied: nvidia-nvjitlink-cu12==12.4.127 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (12.4.127) Requirement already satisfied: triton==3.2.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (3.2.0) Requirement already satisfied: sympy==1.13.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from torch) (1.13.1) Requirement already satisfied: mpmath<1.4,>=1.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from sympy==1.13.1->torch) (1.3.0) Requirement already satisfied: botocore<1.38.0,>=1.37.7 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3) (1.37.7) Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3) (1.0.1) Requirement already satisfied: s3transfer<0.12.0,>=0.11.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from boto3) (0.11.2) Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from botocore<1.38.0,>=1.37.7->boto3) (2.9.0.post0) Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from botocore<1.38.0,>=1.37.7->boto3) (2.3.0) Requirement already satisfied: contourpy>=1.0.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (1.3.1) Requirement already satisfied: cycler>=0.10 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (4.56.0) Requirement already satisfied: kiwisolver>=1.3.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (1.4.7) Requirement already satisfied: packaging>=20.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (21.3) Requirement already satisfied: pyparsing>=2.3.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from matplotlib>=3.3.0->ultralytics) (3.2.1) Requirement already satisfied: pytz>=2020.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from pandas>=1.1.4->ultralytics) (2025.1) Requirement already satisfied: charset_normalizer<4,>=2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from requests>=2.23.0->ultralytics) (3.4.1) Requirement already satisfied: idna<4,>=2.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from requests>=2.23.0->ultralytics) (3.10) Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from requests>=2.23.0->ultralytics) (2025.1.31) Requirement already satisfied: MarkupSafe>=2.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from jinja2->torch) (3.0.2) Requirement already satisfied: six>=1.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.38.0,>=1.37.7->boto3) (1.17.0)
import torch
from ultralytics import YOLO
# Check GPU availability
device = "cuda" if torch.cuda.is_available() else "cpu"
print("Using device:", device)
Using device: cuda
import os
os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
!nvidia-smi
Tue Mar 25 06:10:39 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.144.03 Driver Version: 550.144.03 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA A10G On | 00000000:00:1E.0 Off | 0 |
| 0% 35C P8 18W / 300W | 4MiB / 23028MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
import boto3
def download_files_from_bucket(file,bucket):
'''
this function is for downloading the files from the bucket to the local instance
'''
bucket_name = bucket
file_key = file
local_file_path = file
s3 = boto3.client('s3')
s3.download_file(bucket_name, file_key, local_file_path)
print(f"File downloaded to {local_file_path}")
download_files_from_bucket('stanford-car-dataset-by-classes-folder.zip','pgp-capstone-project')
File downloaded to stanford-car-dataset-by-classes-folder.zip
zip_file_path = 'stanford-car-dataset-by-classes-folder.zip'
!unzip -oq stanford-car-dataset-by-classes-folder.zip
import numpy as np
import pandas as pd
from pathlib import Path
import shutil
from matplotlib import pyplot as plt
from matplotlib import patches
import cv2
import yaml
import glob # for file path handling
from PIL import Image # For image loading and manipulation
import xml.etree.ElementTree as ET # For handling XML annotations (common for object detection datasets)
from sklearn.model_selection import train_test_split #for model selection
from sklearn.preprocessing import LabelEncoder
from ultralytics import YOLO
Loading Training Annotations, Test Annotations and image class
train_annotations_df = pd.read_csv( "anno_train.csv",header=None)
test_annotations_df = pd.read_csv( "anno_test.csv",header=None)
image_class_df = pd.read_csv( "names.csv",header=None)
renaming columns of train, test and image class
train_annotations_df.rename(columns={0:"image_name",1:"xmin",2:"ymin",3:'xmax',4:'ymax',5:'image_class'},inplace=True)
test_annotations_df.rename(columns={0:"image_name",1:"xmin",2:"ymin",3:'xmax',4:'ymax',5:'image_class'},inplace=True)
image_class_df.rename(columns={0:'image_name'},inplace=True)
displaying first 5 values of class names and annotations
image_class_df.head()
| image_name | |
|---|---|
| 0 | AM General Hummer SUV 2000 |
| 1 | Acura RL Sedan 2012 |
| 2 | Acura TL Sedan 2012 |
| 3 | Acura TL Type-S 2008 |
| 4 | Acura TSX Sedan 2012 |
train_annotations_df.head(5)
| image_name | xmin | ymin | xmax | ymax | image_class | |
|---|---|---|---|---|---|---|
| 0 | 00001.jpg | 39 | 116 | 569 | 375 | 14 |
| 1 | 00002.jpg | 36 | 116 | 868 | 587 | 3 |
| 2 | 00003.jpg | 85 | 109 | 601 | 381 | 91 |
| 3 | 00004.jpg | 621 | 393 | 1484 | 1096 | 134 |
| 4 | 00005.jpg | 14 | 36 | 133 | 99 | 106 |
test_annotations_df.head()
| image_name | xmin | ymin | xmax | ymax | image_class | |
|---|---|---|---|---|---|---|
| 0 | 00001.jpg | 30 | 52 | 246 | 147 | 181 |
| 1 | 00002.jpg | 100 | 19 | 576 | 203 | 103 |
| 2 | 00003.jpg | 51 | 105 | 968 | 659 | 145 |
| 3 | 00004.jpg | 67 | 84 | 581 | 407 | 187 |
| 4 | 00005.jpg | 140 | 151 | 593 | 339 | 185 |
finding out the min and max value of the classifications in train and test
train_annotations_df['image_class'].min(),train_annotations_df['image_class'].max()
(1, 196)
test_annotations_df['image_class'].min(),test_annotations_df['image_class'].max()
(1, 196)
finding out the missing classes in training and testing
the classnames in image_class_df starts with 0 and in annotations starts with 1 hence adding 1 to imageclass_df
expected_class_ids = set(range(1,len(image_class_df)+1))
min(expected_class_ids),max(expected_class_ids)
(1, 196)
train_class_ids = set(train_annotations_df["image_class"].unique())
test_class_ids = set(test_annotations_df["image_class"].unique())
missing_in_train = expected_class_ids - train_class_ids
missing_in_test = expected_class_ids - test_class_ids
missing_in_train
set()
missing_in_test
set()
missing_train_class_names = image_class_df.iloc[list(missing_in_train)].values.flatten().tolist()
missing_test_class_names = image_class_df.iloc[list(missing_in_test)].values.flatten().tolist()
print(f"Missing class IDs in training set: {sorted(missing_in_train)}")
print(f"Missing class names in training set: {missing_train_class_names}")
Missing class IDs in training set: [] Missing class names in training set: []
print(f"Missing class IDs in testing set: {sorted(missing_in_test)}")
print(f"Missing class names in testing set: {missing_test_class_names}")
Missing class IDs in testing set: [] Missing class names in testing set: []
Adding one more column in image_class_df to have class_id from 1 to 196 to be in sync with annotation data set. this will be helpful in searching and merging of data
image_class_df.reset_index(drop=True, inplace=True)
image_class_df.insert(0, "class_id", image_class_df.index + 1)
image_class_df.head()
| class_id | image_name | |
|---|---|---|
| 0 | 1 | AM General Hummer SUV 2000 |
| 1 | 2 | Acura RL Sedan 2012 |
| 2 | 3 | Acura TL Sedan 2012 |
| 3 | 4 | Acura TL Type-S 2008 |
| 4 | 5 | Acura TSX Sedan 2012 |
Creation Of Directories for YOLO Processing
-dataset/
-├── images/
-│ ├── train/
-│ ├── val/
-│ └── test/
-├── labels/
-│ ├── train/
-│ ├── val/
-│ └── test/
dataset_path = Path("dataset")
dirs = [
dataset_path / "images" / "train",
dataset_path / "images" / "val",
dataset_path / "images" / "test",
dataset_path / "labels" / "train",
dataset_path / "labels" / "val",
dataset_path / "labels" / "test"
]
for d in dirs:
d.mkdir(parents=True, exist_ok=True)
Splitting the training Data into train and validation
train_annotations_df["image_class"] = train_annotations_df["image_class"].astype(int)
train_df, val_df = train_test_split(
train_annotations_df,
test_size=0.2,
stratify=train_annotations_df["image_class"],
random_state=42
)
checking the shape of train and validation data set
train_df.shape
(6515, 6)
val_df.shape
(1629, 6)
Mapping classid and clasnames
class_map = {
class_id: name.strip().replace("/", "-")
for class_id, name in zip(image_class_df["class_id"], image_class_df["image_name"])
}
class_map
{1: 'AM General Hummer SUV 2000',
2: 'Acura RL Sedan 2012',
3: 'Acura TL Sedan 2012',
4: 'Acura TL Type-S 2008',
5: 'Acura TSX Sedan 2012',
6: 'Acura Integra Type R 2001',
7: 'Acura ZDX Hatchback 2012',
8: 'Aston Martin V8 Vantage Convertible 2012',
9: 'Aston Martin V8 Vantage Coupe 2012',
10: 'Aston Martin Virage Convertible 2012',
11: 'Aston Martin Virage Coupe 2012',
12: 'Audi RS 4 Convertible 2008',
13: 'Audi A5 Coupe 2012',
14: 'Audi TTS Coupe 2012',
15: 'Audi R8 Coupe 2012',
16: 'Audi V8 Sedan 1994',
17: 'Audi 100 Sedan 1994',
18: 'Audi 100 Wagon 1994',
19: 'Audi TT Hatchback 2011',
20: 'Audi S6 Sedan 2011',
21: 'Audi S5 Convertible 2012',
22: 'Audi S5 Coupe 2012',
23: 'Audi S4 Sedan 2012',
24: 'Audi S4 Sedan 2007',
25: 'Audi TT RS Coupe 2012',
26: 'BMW ActiveHybrid 5 Sedan 2012',
27: 'BMW 1 Series Convertible 2012',
28: 'BMW 1 Series Coupe 2012',
29: 'BMW 3 Series Sedan 2012',
30: 'BMW 3 Series Wagon 2012',
31: 'BMW 6 Series Convertible 2007',
32: 'BMW X5 SUV 2007',
33: 'BMW X6 SUV 2012',
34: 'BMW M3 Coupe 2012',
35: 'BMW M5 Sedan 2010',
36: 'BMW M6 Convertible 2010',
37: 'BMW X3 SUV 2012',
38: 'BMW Z4 Convertible 2012',
39: 'Bentley Continental Supersports Conv. Convertible 2012',
40: 'Bentley Arnage Sedan 2009',
41: 'Bentley Mulsanne Sedan 2011',
42: 'Bentley Continental GT Coupe 2012',
43: 'Bentley Continental GT Coupe 2007',
44: 'Bentley Continental Flying Spur Sedan 2007',
45: 'Bugatti Veyron 16.4 Convertible 2009',
46: 'Bugatti Veyron 16.4 Coupe 2009',
47: 'Buick Regal GS 2012',
48: 'Buick Rainier SUV 2007',
49: 'Buick Verano Sedan 2012',
50: 'Buick Enclave SUV 2012',
51: 'Cadillac CTS-V Sedan 2012',
52: 'Cadillac SRX SUV 2012',
53: 'Cadillac Escalade EXT Crew Cab 2007',
54: 'Chevrolet Silverado 1500 Hybrid Crew Cab 2012',
55: 'Chevrolet Corvette Convertible 2012',
56: 'Chevrolet Corvette ZR1 2012',
57: 'Chevrolet Corvette Ron Fellows Edition Z06 2007',
58: 'Chevrolet Traverse SUV 2012',
59: 'Chevrolet Camaro Convertible 2012',
60: 'Chevrolet HHR SS 2010',
61: 'Chevrolet Impala Sedan 2007',
62: 'Chevrolet Tahoe Hybrid SUV 2012',
63: 'Chevrolet Sonic Sedan 2012',
64: 'Chevrolet Express Cargo Van 2007',
65: 'Chevrolet Avalanche Crew Cab 2012',
66: 'Chevrolet Cobalt SS 2010',
67: 'Chevrolet Malibu Hybrid Sedan 2010',
68: 'Chevrolet TrailBlazer SS 2009',
69: 'Chevrolet Silverado 2500HD Regular Cab 2012',
70: 'Chevrolet Silverado 1500 Classic Extended Cab 2007',
71: 'Chevrolet Express Van 2007',
72: 'Chevrolet Monte Carlo Coupe 2007',
73: 'Chevrolet Malibu Sedan 2007',
74: 'Chevrolet Silverado 1500 Extended Cab 2012',
75: 'Chevrolet Silverado 1500 Regular Cab 2012',
76: 'Chrysler Aspen SUV 2009',
77: 'Chrysler Sebring Convertible 2010',
78: 'Chrysler Town and Country Minivan 2012',
79: 'Chrysler 300 SRT-8 2010',
80: 'Chrysler Crossfire Convertible 2008',
81: 'Chrysler PT Cruiser Convertible 2008',
82: 'Daewoo Nubira Wagon 2002',
83: 'Dodge Caliber Wagon 2012',
84: 'Dodge Caliber Wagon 2007',
85: 'Dodge Caravan Minivan 1997',
86: 'Dodge Ram Pickup 3500 Crew Cab 2010',
87: 'Dodge Ram Pickup 3500 Quad Cab 2009',
88: 'Dodge Sprinter Cargo Van 2009',
89: 'Dodge Journey SUV 2012',
90: 'Dodge Dakota Crew Cab 2010',
91: 'Dodge Dakota Club Cab 2007',
92: 'Dodge Magnum Wagon 2008',
93: 'Dodge Challenger SRT8 2011',
94: 'Dodge Durango SUV 2012',
95: 'Dodge Durango SUV 2007',
96: 'Dodge Charger Sedan 2012',
97: 'Dodge Charger SRT-8 2009',
98: 'Eagle Talon Hatchback 1998',
99: 'FIAT 500 Abarth 2012',
100: 'FIAT 500 Convertible 2012',
101: 'Ferrari FF Coupe 2012',
102: 'Ferrari California Convertible 2012',
103: 'Ferrari 458 Italia Convertible 2012',
104: 'Ferrari 458 Italia Coupe 2012',
105: 'Fisker Karma Sedan 2012',
106: 'Ford F-450 Super Duty Crew Cab 2012',
107: 'Ford Mustang Convertible 2007',
108: 'Ford Freestar Minivan 2007',
109: 'Ford Expedition EL SUV 2009',
110: 'Ford Edge SUV 2012',
111: 'Ford Ranger SuperCab 2011',
112: 'Ford GT Coupe 2006',
113: 'Ford F-150 Regular Cab 2012',
114: 'Ford F-150 Regular Cab 2007',
115: 'Ford Focus Sedan 2007',
116: 'Ford E-Series Wagon Van 2012',
117: 'Ford Fiesta Sedan 2012',
118: 'GMC Terrain SUV 2012',
119: 'GMC Savana Van 2012',
120: 'GMC Yukon Hybrid SUV 2012',
121: 'GMC Acadia SUV 2012',
122: 'GMC Canyon Extended Cab 2012',
123: 'Geo Metro Convertible 1993',
124: 'HUMMER H3T Crew Cab 2010',
125: 'HUMMER H2 SUT Crew Cab 2009',
126: 'Honda Odyssey Minivan 2012',
127: 'Honda Odyssey Minivan 2007',
128: 'Honda Accord Coupe 2012',
129: 'Honda Accord Sedan 2012',
130: 'Hyundai Veloster Hatchback 2012',
131: 'Hyundai Santa Fe SUV 2012',
132: 'Hyundai Tucson SUV 2012',
133: 'Hyundai Veracruz SUV 2012',
134: 'Hyundai Sonata Hybrid Sedan 2012',
135: 'Hyundai Elantra Sedan 2007',
136: 'Hyundai Accent Sedan 2012',
137: 'Hyundai Genesis Sedan 2012',
138: 'Hyundai Sonata Sedan 2012',
139: 'Hyundai Elantra Touring Hatchback 2012',
140: 'Hyundai Azera Sedan 2012',
141: 'Infiniti G Coupe IPL 2012',
142: 'Infiniti QX56 SUV 2011',
143: 'Isuzu Ascender SUV 2008',
144: 'Jaguar XK XKR 2012',
145: 'Jeep Patriot SUV 2012',
146: 'Jeep Wrangler SUV 2012',
147: 'Jeep Liberty SUV 2012',
148: 'Jeep Grand Cherokee SUV 2012',
149: 'Jeep Compass SUV 2012',
150: 'Lamborghini Reventon Coupe 2008',
151: 'Lamborghini Aventador Coupe 2012',
152: 'Lamborghini Gallardo LP 570-4 Superleggera 2012',
153: 'Lamborghini Diablo Coupe 2001',
154: 'Land Rover Range Rover SUV 2012',
155: 'Land Rover LR2 SUV 2012',
156: 'Lincoln Town Car Sedan 2011',
157: 'MINI Cooper Roadster Convertible 2012',
158: 'Maybach Landaulet Convertible 2012',
159: 'Mazda Tribute SUV 2011',
160: 'McLaren MP4-12C Coupe 2012',
161: 'Mercedes-Benz 300-Class Convertible 1993',
162: 'Mercedes-Benz C-Class Sedan 2012',
163: 'Mercedes-Benz SL-Class Coupe 2009',
164: 'Mercedes-Benz E-Class Sedan 2012',
165: 'Mercedes-Benz S-Class Sedan 2012',
166: 'Mercedes-Benz Sprinter Van 2012',
167: 'Mitsubishi Lancer Sedan 2012',
168: 'Nissan Leaf Hatchback 2012',
169: 'Nissan NV Passenger Van 2012',
170: 'Nissan Juke Hatchback 2012',
171: 'Nissan 240SX Coupe 1998',
172: 'Plymouth Neon Coupe 1999',
173: 'Porsche Panamera Sedan 2012',
174: 'Ram C-V Cargo Van Minivan 2012',
175: 'Rolls-Royce Phantom Drophead Coupe Convertible 2012',
176: 'Rolls-Royce Ghost Sedan 2012',
177: 'Rolls-Royce Phantom Sedan 2012',
178: 'Scion xD Hatchback 2012',
179: 'Spyker C8 Convertible 2009',
180: 'Spyker C8 Coupe 2009',
181: 'Suzuki Aerio Sedan 2007',
182: 'Suzuki Kizashi Sedan 2012',
183: 'Suzuki SX4 Hatchback 2012',
184: 'Suzuki SX4 Sedan 2012',
185: 'Tesla Model S Sedan 2012',
186: 'Toyota Sequoia SUV 2012',
187: 'Toyota Camry Sedan 2012',
188: 'Toyota Corolla Sedan 2012',
189: 'Toyota 4Runner SUV 2012',
190: 'Volkswagen Golf Hatchback 2012',
191: 'Volkswagen Golf Hatchback 1991',
192: 'Volkswagen Beetle Hatchback 2012',
193: 'Volvo C30 Hatchback 2012',
194: 'Volvo 240 Sedan 1993',
195: 'Volvo XC90 SUV 2007',
196: 'smart fortwo Convertible 2012'}
Moving the images and labels to the respective yolo directories.
The bounding boxes are normalized for YOLO format
def move_and_create_labels(df, src_dir, dst_img_dir, dst_lbl_dir, class_map):
for _, row in df.iterrows():
img_name = row["image_name"]
class_id = int(row["image_class"])
class_id_yolo = class_id - 1 # YOLO expects 0-based
class_name = class_map[class_id]
# Source image
src_img_path = src_dir / class_name / img_name
# Destination paths
dst_img_path = dst_img_dir / img_name
dst_lbl_path = dst_lbl_dir / img_name.replace(".jpg", ".txt")
if not src_img_path.exists():
print(f"Missing image: {src_img_path}")
continue
# Copy image
shutil.copy(src_img_path, dst_img_path)
# Read image dimensions
img = cv2.imread(str(src_img_path))
if img is None:
print(f"Unreadable image: {src_img_path}")
continue
h, w = img.shape[:2]
# Normalize bounding box
x_center_raw = ((row["xmin"] + row["xmax"]) / 2) / w
y_center_raw = ((row["ymin"] + row["ymax"]) / 2) / h
width_raw = (row["xmax"] - row["xmin"]) / w
height_raw = (row["ymax"] - row["ymin"]) / h
#outlier logging.
if any(v > 1.1 or v < 0 for v in [x_center_raw, y_center_raw, width_raw, height_raw]):
print(f"Out-of-bounds bbox in {img_name}: "
f"x_center={x_center_raw:.2f}, y_center={y_center_raw:.2f}, "
f"w={width_raw:.2f}, h={height_raw:.2f}")
# clamping outliers to make it to safe YOLO format
x_center = min(max(x_center_raw, 0), 1)
y_center = min(max(y_center_raw, 0), 1)
width = min(max(width_raw, 0), 1)
height = min(max(height_raw, 0), 1)
# Write YOLO-format label
with open(dst_lbl_path, "w") as f:
f.write(f"{class_id_yolo} {x_center:.6f} {y_center:.6f} {width:.6f} {height:.6f}\n")
print(f"Done: {len(df)} samples → {dst_img_dir.name}/ + {dst_lbl_dir.name}/")
src_base_train_dir = Path("car_data/car_data/train")
src_base_test_dir = Path("car_data/car_data/test")
dst_img_train = Path("dataset/images/train")
dst_lbl_train = Path("dataset/labels/train")
dst_img_val = Path("dataset/images/val")
dst_lbl_val = Path("dataset/labels/val")
dst_img_test = Path("dataset/images/test")
dst_lbl_test = Path("dataset/labels/test")
Moving the images and Labels
move_and_create_labels(train_df, src_base_train_dir, dst_img_train, dst_lbl_train, class_map)
Out-of-bounds bbox in 07389.jpg: x_center=0.67, y_center=0.40, w=1.15, h=0.56 Done: 6515 samples → train/ + train/
move_and_create_labels(val_df, src_base_train_dir, dst_img_val, dst_lbl_val, class_map)
Done: 1629 samples → val/ + val/
move_and_create_labels(test_annotations_df, src_base_test_dir, dst_img_test, dst_lbl_test, class_map)
Done: 8041 samples → test/ + test/
Creating Data.yml for YOLO
dataset_path = Path("dataset")
class_names = (
image_class_df
.sort_values("class_id")["image_name"]
.str.replace("/", "-", regex=False)
.tolist()
)
data_yaml = {
"path": str(dataset_path.resolve()), # absolute path to dataset
"train": "images/train",
"val": "images/val",
"test": "images/test",
"nc": len(class_names),
"names": class_names
}
with open(dataset_path / "data.yaml", "w") as f:
yaml.dump(data_yaml, f)
print("data.yaml generated at:", dataset_path / "data.yaml")
data.yaml generated at: dataset/data.yaml
THE YOLO MODEL
model = YOLO("yolov8l.pt") # Options: yolov8n.pt (small), yolov8m.pt (medium), yolov8l.pt (large)
Downloading https://github.com/ultralytics/assets/releases/download/v8.3.0/yolov8l.pt to 'yolov8l.pt'...
100%|██████████| 83.7M/83.7M [00:00<00:00, 330MB/s]
train_metrics = model.train(data="dataset/data.yaml", epochs=50, imgsz=640, batch=16, device="cuda")
Ultralytics 8.3.96 🚀 Python-3.10.16 torch-2.6.0+cu124 CUDA:0 (NVIDIA A10G, 22503MiB) engine/trainer: task=detect, mode=train, model=yolov8l.pt, data=dataset/data.yaml, epochs=50, time=None, patience=100, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=cuda, workers=8, project=None, name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=True, opset=None, workspace=None, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, copy_paste_mode=flip, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train Overriding model.yaml nc=80 with nc=196 from n params module arguments 0 -1 1 1856 ultralytics.nn.modules.conv.Conv [3, 64, 3, 2] 1 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2] 2 -1 3 279808 ultralytics.nn.modules.block.C2f [128, 128, 3, True] 3 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2] 4 -1 6 2101248 ultralytics.nn.modules.block.C2f [256, 256, 6, True] 5 -1 1 1180672 ultralytics.nn.modules.conv.Conv [256, 512, 3, 2] 6 -1 6 8396800 ultralytics.nn.modules.block.C2f [512, 512, 6, True] 7 -1 1 2360320 ultralytics.nn.modules.conv.Conv [512, 512, 3, 2] 8 -1 3 4461568 ultralytics.nn.modules.block.C2f [512, 512, 3, True] 9 -1 1 656896 ultralytics.nn.modules.block.SPPF [512, 512, 5] 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1] 12 -1 3 4723712 ultralytics.nn.modules.block.C2f [1024, 512, 3] 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1] 15 -1 3 1247744 ultralytics.nn.modules.block.C2f [768, 256, 3] 16 -1 1 590336 ultralytics.nn.modules.conv.Conv [256, 256, 3, 2] 17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1] 18 -1 3 4592640 ultralytics.nn.modules.block.C2f [768, 512, 3] 19 -1 1 2360320 ultralytics.nn.modules.conv.Conv [512, 512, 3, 2] 20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1] 21 -1 3 4723712 ultralytics.nn.modules.block.C2f [1024, 512, 3] 22 [15, 18, 21] 1 5733916 ultralytics.nn.modules.head.Detect [196, [256, 512, 512]] Model summary: 209 layers, 43,780,956 parameters, 43,780,940 gradients, 166.2 GFLOPs Transferred 589/595 items from pretrained weights Freezing layer 'model.22.dfl.conv.weight' AMP: running Automatic Mixed Precision (AMP) checks... Downloading https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt to 'yolo11n.pt'...
100%|██████████| 5.35M/5.35M [00:00<00:00, 294MB/s]
AMP: checks passed ✅
train: Scanning /home/ec2-user/SageMaker/dataset/labels/train... 6515 images, 0 backgrounds, 0 corrupt: 100%|██████████| 6515/6515 [00:05<00:00, 1281.16it/s]
train: New cache created: /home/ec2-user/SageMaker/dataset/labels/train.cache
val: Scanning /home/ec2-user/SageMaker/dataset/labels/val... 1629 images, 0 backgrounds, 0 corrupt: 100%|██████████| 1629/1629 [00:01<00:00, 1160.03it/s]
val: New cache created: /home/ec2-user/SageMaker/dataset/labels/val.cache
Plotting labels to runs/detect/train/labels.jpg... optimizer: 'optimizer=auto' found, ignoring 'lr0=0.01' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... optimizer: AdamW(lr=5e-05, momentum=0.9) with parameter groups 97 weight(decay=0.0), 104 weight(decay=0.0005), 103 bias(decay=0.0) Image sizes 640 train, 640 val Using 8 dataloader workers Logging results to runs/detect/train Starting training for 50 epochs... Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
1/50 9.64G 0.5089 4.433 1.127 6 640: 100%|██████████| 408/408 [02:29<00:00, 2.73it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:12<00:00, 4.19it/s]
all 1629 1629 0.547 0.0741 0.0517 0.0475
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
2/50 13.7G 0.4619 3.422 1.07 6 640: 100%|██████████| 408/408 [02:25<00:00, 2.81it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:12<00:00, 4.24it/s]
all 1629 1629 0.319 0.287 0.189 0.174
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
3/50 13.7G 0.4697 2.793 1.059 7 640: 100%|██████████| 408/408 [02:24<00:00, 2.83it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.407 0.479 0.428 0.4
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
4/50 13.7G 0.4501 2.289 1.041 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.512 0.579 0.598 0.558
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
5/50 13.8G 0.4342 1.927 1.027 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.61 0.619 0.69 0.647
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
6/50 13.8G 0.4264 1.646 1.017 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.716 0.72 0.799 0.749
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
7/50 13.9G 0.4227 1.468 1.014 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.767 0.746 0.838 0.79
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
8/50 13.9G 0.4093 1.286 1.007 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.745 0.793 0.859 0.807
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
9/50 14G 0.4072 1.161 1.003 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.808 0.809 0.886 0.837
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
10/50 14G 0.3992 1.073 0.9972 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.826 0.831 0.897 0.845
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
11/50 14G 0.3952 0.9961 0.9933 4 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.855 0.843 0.907 0.855
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
12/50 14.1G 0.3882 0.9306 0.9911 5 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.83 0.832 0.905 0.855
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
13/50 14.1G 0.389 0.893 0.9893 12 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.866 0.869 0.925 0.876
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
14/50 14.2G 0.3911 0.8514 0.9895 10 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.863 0.861 0.926 0.877
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
15/50 14.2G 0.3801 0.8062 0.9839 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.869 0.866 0.925 0.874
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
16/50 14.3G 0.3775 0.7593 0.9837 6 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.887 0.88 0.933 0.882
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
17/50 14.3G 0.3749 0.7263 0.9807 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.896 0.879 0.935 0.887
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
18/50 14.3G 0.3767 0.7065 0.9795 12 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.882 0.885 0.938 0.889
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
19/50 14.4G 0.3689 0.681 0.9754 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:12<00:00, 4.25it/s]
all 1629 1629 0.884 0.908 0.938 0.888
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
20/50 14.4G 0.3681 0.6616 0.9778 7 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.885 0.898 0.939 0.889
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
21/50 14.7G 0.3583 0.6223 0.9684 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.885 0.905 0.944 0.895
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
22/50 14.9G 0.3622 0.6299 0.9741 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.88 0.906 0.941 0.891
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
23/50 15.2G 0.3538 0.603 0.9685 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.891 0.907 0.943 0.893
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
24/50 15.4G 0.355 0.5885 0.968 10 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.889 0.909 0.942 0.892
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
25/50 15.6G 0.3547 0.5707 0.9674 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.9 0.896 0.94 0.893
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
26/50 15.9G 0.3501 0.5642 0.9646 11 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.886 0.912 0.941 0.893
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
27/50 16.1G 0.3481 0.5512 0.9647 6 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.25it/s]
all 1629 1629 0.894 0.918 0.945 0.898
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
28/50 16.4G 0.3423 0.5349 0.9594 10 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.891 0.911 0.946 0.898
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
29/50 16.6G 0.3419 0.524 0.9615 7 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.913 0.91 0.949 0.902
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
30/50 16.9G 0.3388 0.5033 0.9564 12 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.896 0.903 0.942 0.894
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
31/50 17.1G 0.3379 0.5025 0.959 4 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.896 0.919 0.945 0.894
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
32/50 17.3G 0.3332 0.4733 0.9553 7 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.91 0.911 0.946 0.897
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
33/50 17.6G 0.3256 0.4605 0.9511 8 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.899 0.914 0.946 0.899
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
34/50 17.8G 0.3242 0.4568 0.9508 10 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.918 0.904 0.947 0.896
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
35/50 18.1G 0.325 0.4441 0.95 6 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.899 0.917 0.949 0.902
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
36/50 18.3G 0.3223 0.443 0.9512 7 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.916 0.908 0.945 0.895
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
37/50 18.5G 0.3185 0.4394 0.9505 6 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.896 0.922 0.946 0.897
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
38/50 18.8G 0.3173 0.4205 0.9491 10 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.913 0.905 0.947 0.898
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
39/50 19G 0.3155 0.4094 0.9447 9 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.913 0.916 0.945 0.895
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
40/50 19.3G 0.3144 0.4104 0.9451 6 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.922 0.905 0.948 0.899
Closing dataloader mosaic
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
41/50 19.5G 0.2305 0.203 0.8821 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.83it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:12<00:00, 4.25it/s]
all 1629 1629 0.916 0.899 0.944 0.897
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
42/50 19.7G 0.2253 0.1914 0.881 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.27it/s]
all 1629 1629 0.914 0.905 0.943 0.895
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
43/50 20G 0.2217 0.1777 0.8787 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.26it/s]
all 1629 1629 0.912 0.907 0.946 0.9
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
44/50 10.3G 0.2171 0.1736 0.878 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.28it/s]
all 1629 1629 0.903 0.918 0.944 0.896
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
45/50 13.6G 0.2137 0.1633 0.8716 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.29it/s]
all 1629 1629 0.903 0.915 0.947 0.9
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
46/50 13.6G 0.2069 0.1573 0.87 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.29it/s]
all 1629 1629 0.916 0.915 0.947 0.901
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
47/50 13.6G 0.2042 0.155 0.8685 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.29it/s]
all 1629 1629 0.924 0.909 0.948 0.902
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
48/50 13.6G 0.202 0.152 0.8665 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.28it/s]
all 1629 1629 0.913 0.915 0.946 0.899
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
49/50 13.6G 0.1981 0.1473 0.8668 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.29it/s]
all 1629 1629 0.922 0.908 0.948 0.901
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
50/50 13.6G 0.196 0.1437 0.8636 3 640: 100%|██████████| 408/408 [02:23<00:00, 2.84it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.28it/s]
all 1629 1629 0.913 0.918 0.949 0.902
50 epochs completed in 2.186 hours. Optimizer stripped from runs/detect/train/weights/last.pt, 88.0MB Optimizer stripped from runs/detect/train/weights/best.pt, 88.0MB Validating runs/detect/train/weights/best.pt... Ultralytics 8.3.96 🚀 Python-3.10.16 torch-2.6.0+cu124 CUDA:0 (NVIDIA A10G, 22503MiB) Model summary (fused): 112 layers, 43,757,724 parameters, 0 gradients, 165.7 GFLOPs
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 51/51 [00:11<00:00, 4.46it/s]
all 1629 1629 0.924 0.909 0.948 0.902
AM General Hummer SUV 2000 9 9 0.867 1 0.962 0.903
Acura RL Sedan 2012 6 6 0.939 0.833 0.922 0.922
Acura TL Sedan 2012 9 9 0.996 1 0.995 0.78
Acura TL Type-S 2008 8 8 0.973 1 0.995 0.995
Acura TSX Sedan 2012 8 8 0.875 1 0.982 0.925
Acura Integra Type R 2001 9 9 0.968 1 0.995 0.974
Acura ZDX Hatchback 2012 8 8 0.963 1 0.995 0.983
Aston Martin V8 Vantage Convertible 2012 9 9 0.856 0.662 0.829 0.783
Aston Martin V8 Vantage Coupe 2012 8 8 0.863 0.791 0.884 0.803
Aston Martin Virage Convertible 2012 6 6 0.817 0.833 0.793 0.728
Aston Martin Virage Coupe 2012 8 8 0.954 0.875 0.931 0.834
Audi RS 4 Convertible 2008 7 7 0.967 0.857 0.883 0.734
Audi A5 Coupe 2012 8 8 0.883 0.945 0.898 0.898
Audi TTS Coupe 2012 9 9 0.472 0.302 0.553 0.553
Audi R8 Coupe 2012 9 9 1 0.795 0.907 0.885
Audi V8 Sedan 1994 9 9 0.771 0.889 0.83 0.783
Audi 100 Sedan 1994 8 8 0.587 0.75 0.823 0.779
Audi 100 Wagon 1994 9 9 0.982 0.556 0.812 0.728
Audi TT Hatchback 2011 8 8 0.616 0.603 0.584 0.554
Audi S6 Sedan 2011 9 9 0.991 1 0.995 0.985
Audi S5 Convertible 2012 8 8 0.846 1 0.967 0.94
Audi S5 Coupe 2012 9 9 0.948 0.667 0.806 0.641
Audi S4 Sedan 2012 8 8 1 0.932 0.995 0.973
Audi S4 Sedan 2007 9 9 0.983 1 0.995 0.98
Audi TT RS Coupe 2012 8 8 0.937 0.875 0.982 0.951
BMW ActiveHybrid 5 Sedan 2012 7 7 0.953 1 0.995 0.963
BMW 1 Series Convertible 2012 7 7 0.753 1 0.806 0.789
BMW 1 Series Coupe 2012 8 8 1 0.782 0.995 0.791
BMW 3 Series Sedan 2012 9 9 0.867 0.729 0.941 0.916
BMW 3 Series Wagon 2012 8 8 1 0.783 0.939 0.828
BMW 6 Series Convertible 2007 9 9 0.964 1 0.995 0.897
BMW X5 SUV 2007 8 8 0.986 1 0.995 0.93
BMW X6 SUV 2012 8 8 0.991 1 0.995 0.984
BMW M3 Coupe 2012 9 9 1 0.935 0.995 0.995
BMW M5 Sedan 2010 8 8 0.886 1 0.954 0.942
BMW M6 Convertible 2010 8 8 0.979 1 0.995 0.984
BMW X3 SUV 2012 8 8 1 0.873 0.995 0.981
BMW Z4 Convertible 2012 8 8 1 0.916 0.995 0.933
Bentley Continental Supersports Conv. Convertible 2012 7 7 1 0.802 0.978 0.912
Bentley Arnage Sedan 2009 8 8 0.864 0.875 0.971 0.894
Bentley Mulsanne Sedan 2011 7 7 1 0.921 0.995 0.983
Bentley Continental GT Coupe 2012 7 7 0.937 0.714 0.933 0.911
Bentley Continental GT Coupe 2007 9 9 0.62 0.889 0.943 0.943
Bentley Continental Flying Spur Sedan 2007 9 9 1 0.811 0.995 0.995
Bugatti Veyron 16.4 Convertible 2009 6 6 0.611 0.833 0.663 0.63
Bugatti Veyron 16.4 Coupe 2009 9 9 1 0.866 0.995 0.94
Buick Regal GS 2012 7 7 0.962 1 0.995 0.984
Buick Rainier SUV 2007 9 9 0.981 0.889 0.917 0.917
Buick Verano Sedan 2012 7 7 0.974 1 0.995 0.995
Buick Enclave SUV 2012 8 8 0.963 1 0.995 0.964
Cadillac CTS-V Sedan 2012 9 9 0.974 1 0.995 0.814
Cadillac SRX SUV 2012 8 8 0.972 1 0.995 0.966
Cadillac Escalade EXT Crew Cab 2007 9 9 0.977 1 0.995 0.957
Chevrolet Silverado 1500 Hybrid Crew Cab 2012 8 8 0.962 0.625 0.928 0.894
Chevrolet Corvette Convertible 2012 8 8 0.869 1 0.995 0.929
Chevrolet Corvette ZR1 2012 9 9 0.965 0.889 0.975 0.902
Chevrolet Corvette Ron Fellows Edition Z06 2007 8 8 0.979 1 0.995 0.983
Chevrolet Traverse SUV 2012 9 9 0.981 1 0.995 0.929
Chevrolet Camaro Convertible 2012 9 9 1 0.922 0.995 0.963
Chevrolet HHR SS 2010 7 7 0.963 1 0.995 0.965
Chevrolet Impala Sedan 2007 9 9 0.968 1 0.995 0.905
Chevrolet Tahoe Hybrid SUV 2012 7 7 0.696 0.714 0.77 0.757
Chevrolet Sonic Sedan 2012 9 9 0.864 1 0.995 0.955
Chevrolet Express Cargo Van 2007 6 6 0.522 0.734 0.716 0.649
Chevrolet Avalanche Crew Cab 2012 9 9 0.881 0.826 0.962 0.953
Chevrolet Cobalt SS 2010 8 8 1 0.804 0.939 0.924
Chevrolet Malibu Hybrid Sedan 2010 8 8 0.984 1 0.995 0.977
Chevrolet TrailBlazer SS 2009 8 8 0.883 0.944 0.912 0.912
Chevrolet Silverado 2500HD Regular Cab 2012 7 7 0.64 0.571 0.663 0.641
Chevrolet Silverado 1500 Classic Extended Cab 2007 9 9 0.957 0.889 0.956 0.918
Chevrolet Express Van 2007 7 7 0.77 0.487 0.803 0.803
Chevrolet Monte Carlo Coupe 2007 9 9 1 0.847 0.899 0.884
Chevrolet Malibu Sedan 2007 9 9 0.905 1 0.995 0.974
Chevrolet Silverado 1500 Extended Cab 2012 9 9 0.609 0.889 0.772 0.748
Chevrolet Silverado 1500 Regular Cab 2012 9 9 0.745 0.778 0.856 0.82
Chrysler Aspen SUV 2009 9 9 0.951 1 0.995 0.932
Chrysler Sebring Convertible 2010 8 8 0.879 0.909 0.982 0.957
Chrysler Town and Country Minivan 2012 8 8 0.878 0.906 0.939 0.899
Chrysler 300 SRT-8 2010 10 10 0.883 1 0.995 0.931
Chrysler Crossfire Convertible 2008 9 9 0.97 1 0.995 0.943
Chrysler PT Cruiser Convertible 2008 9 9 0.97 1 0.995 0.951
Daewoo Nubira Wagon 2002 9 9 0.968 1 0.995 0.972
Dodge Caliber Wagon 2012 8 8 0.765 0.412 0.624 0.608
Dodge Caliber Wagon 2007 8 8 0.621 0.75 0.683 0.676
Dodge Caravan Minivan 1997 9 9 0.968 1 0.995 0.94
Dodge Ram Pickup 3500 Crew Cab 2010 9 9 0.872 1 0.929 0.878
Dodge Ram Pickup 3500 Quad Cab 2009 9 9 0.953 0.889 0.901 0.901
Dodge Sprinter Cargo Van 2009 8 8 0.863 0.789 0.865 0.745
Dodge Journey SUV 2012 9 9 0.872 1 0.895 0.895
Dodge Dakota Crew Cab 2010 8 8 0.779 0.88 0.955 0.931
Dodge Dakota Club Cab 2007 8 8 1 0.816 0.971 0.936
Dodge Magnum Wagon 2008 8 8 1 0.797 0.982 0.92
Dodge Challenger SRT8 2011 8 8 0.994 1 0.995 0.962
Dodge Durango SUV 2012 9 9 0.977 0.889 0.904 0.881
Dodge Durango SUV 2007 9 9 0.982 0.889 0.984 0.897
Dodge Charger Sedan 2012 8 8 0.88 1 0.995 0.995
Dodge Charger SRT-8 2009 8 8 0.865 0.805 0.892 0.87
Eagle Talon Hatchback 1998 9 9 0.967 1 0.995 0.903
FIAT 500 Abarth 2012 5 5 0.97 1 0.995 0.864
FIAT 500 Convertible 2012 7 7 0.961 1 0.995 0.977
Ferrari FF Coupe 2012 8 8 0.953 0.875 0.982 0.934
Ferrari California Convertible 2012 8 8 0.965 1 0.995 0.995
Ferrari 458 Italia Convertible 2012 8 8 0.876 1 0.912 0.828
Ferrari 458 Italia Coupe 2012 9 9 0.865 0.778 0.892 0.828
Fisker Karma Sedan 2012 9 9 0.972 1 0.995 0.98
Ford F-450 Super Duty Crew Cab 2012 8 8 1 0.812 0.995 0.964
Ford Mustang Convertible 2007 9 9 1 0.875 0.995 0.963
Ford Freestar Minivan 2007 9 9 0.974 1 0.995 0.966
Ford Expedition EL SUV 2009 9 9 0.976 1 0.995 0.957
Ford Edge SUV 2012 9 9 1 0.969 0.995 0.912
Ford Ranger SuperCab 2011 8 8 0.961 1 0.995 0.995
Ford GT Coupe 2006 9 9 0.888 0.889 0.932 0.908
Ford F-150 Regular Cab 2012 9 9 0.887 0.871 0.963 0.936
Ford F-150 Regular Cab 2007 9 9 0.887 0.875 0.951 0.938
Ford Focus Sedan 2007 9 9 0.962 1 0.995 0.975
Ford E-Series Wagon Van 2012 8 8 0.966 1 0.995 0.98
Ford Fiesta Sedan 2012 9 9 0.974 1 0.995 0.959
GMC Terrain SUV 2012 8 8 0.979 1 0.995 0.97
GMC Savana Van 2012 14 14 0.86 0.88 0.901 0.886
GMC Yukon Hybrid SUV 2012 9 9 0.902 0.889 0.984 0.972
GMC Acadia SUV 2012 9 9 1 0.947 0.995 0.94
GMC Canyon Extended Cab 2012 8 8 0.958 0.875 0.982 0.932
Geo Metro Convertible 1993 9 9 0.961 1 0.995 0.893
HUMMER H3T Crew Cab 2010 8 8 0.727 0.671 0.803 0.731
HUMMER H2 SUT Crew Cab 2009 9 9 0.85 0.556 0.818 0.782
Honda Odyssey Minivan 2012 8 8 0.966 1 0.995 0.972
Honda Odyssey Minivan 2007 8 8 0.97 1 0.995 0.974
Honda Accord Coupe 2012 8 8 0.97 0.875 0.896 0.884
Honda Accord Sedan 2012 8 8 0.963 1 0.995 0.957
Hyundai Veloster Hatchback 2012 8 8 0.976 1 0.995 0.921
Hyundai Santa Fe SUV 2012 8 8 0.971 1 0.995 0.851
Hyundai Tucson SUV 2012 9 9 0.964 1 0.995 0.966
Hyundai Veracruz SUV 2012 8 8 0.964 1 0.995 0.995
Hyundai Sonata Hybrid Sedan 2012 7 7 1 0.818 0.995 0.985
Hyundai Elantra Sedan 2007 8 8 0.95 0.875 0.892 0.871
Hyundai Accent Sedan 2012 5 5 0.97 1 0.995 0.961
Hyundai Genesis Sedan 2012 9 9 0.98 1 0.995 0.937
Hyundai Sonata Sedan 2012 8 8 0.876 0.884 0.967 0.886
Hyundai Elantra Touring Hatchback 2012 9 9 0.972 1 0.995 0.971
Hyundai Azera Sedan 2012 8 8 0.958 0.875 0.971 0.888
Infiniti G Coupe IPL 2012 7 7 0.972 1 0.995 0.944
Infiniti QX56 SUV 2011 6 6 0.958 1 0.995 0.976
Isuzu Ascender SUV 2008 8 8 0.955 0.75 0.967 0.882
Jaguar XK XKR 2012 9 9 1 0.919 0.995 0.877
Jeep Patriot SUV 2012 9 9 0.962 1 0.995 0.965
Jeep Wrangler SUV 2012 9 9 0.968 1 0.995 0.96
Jeep Liberty SUV 2012 9 9 0.956 0.889 0.984 0.955
Jeep Grand Cherokee SUV 2012 9 9 0.894 0.94 0.973 0.965
Jeep Compass SUV 2012 9 9 0.942 1 0.995 0.995
Lamborghini Reventon Coupe 2008 7 7 0.934 1 0.995 0.589
Lamborghini Aventador Coupe 2012 9 9 1 0.876 0.984 0.92
Lamborghini Gallardo LP 570-4 Superleggera 2012 7 7 0.959 1 0.995 0.943
Lamborghini Diablo Coupe 2001 9 9 0.9 0.889 0.984 0.628
Land Rover Range Rover SUV 2012 9 9 0.967 1 0.995 0.995
Land Rover LR2 SUV 2012 9 9 1 0.956 0.995 0.928
Lincoln Town Car Sedan 2011 8 8 0.932 1 0.995 0.942
MINI Cooper Roadster Convertible 2012 7 7 0.972 1 0.995 0.995
Maybach Landaulet Convertible 2012 6 6 1 0.425 0.972 0.849
Mazda Tribute SUV 2011 7 7 0.945 1 0.995 0.995
McLaren MP4-12C Coupe 2012 9 9 0.865 1 0.984 0.933
Mercedes-Benz 300-Class Convertible 1993 10 10 0.996 0.9 0.978 0.914
Mercedes-Benz C-Class Sedan 2012 9 9 1 0.851 0.984 0.849
Mercedes-Benz SL-Class Coupe 2009 7 7 0.956 1 0.995 0.915
Mercedes-Benz E-Class Sedan 2012 9 9 0.974 1 0.995 0.961
Mercedes-Benz S-Class Sedan 2012 9 9 0.966 1 0.995 0.942
Mercedes-Benz Sprinter Van 2012 8 8 0.836 0.875 0.817 0.741
Mitsubishi Lancer Sedan 2012 10 10 0.965 1 0.995 0.958
Nissan Leaf Hatchback 2012 8 8 0.871 1 0.912 0.88
Nissan NV Passenger Van 2012 8 8 1 0.971 0.995 0.938
Nissan Juke Hatchback 2012 9 9 0.967 1 0.995 0.944
Nissan 240SX Coupe 1998 9 9 0.971 1 0.995 0.95
Plymouth Neon Coupe 1999 9 9 0.968 0.889 0.916 0.906
Porsche Panamera Sedan 2012 9 9 1 0.946 0.995 0.976
Ram C-V Cargo Van Minivan 2012 8 8 0.962 0.875 0.889 0.768
Rolls-Royce Phantom Drophead Coupe Convertible 2012 6 6 0.957 1 0.995 0.965
Rolls-Royce Ghost Sedan 2012 8 8 0.806 0.75 0.775 0.77
Rolls-Royce Phantom Sedan 2012 9 9 0.764 0.721 0.766 0.669
Scion xD Hatchback 2012 8 8 0.971 1 0.995 0.956
Spyker C8 Convertible 2009 9 9 0.815 0.778 0.838 0.838
Spyker C8 Coupe 2009 9 9 0.791 0.889 0.819 0.781
Suzuki Aerio Sedan 2007 8 8 0.966 1 0.995 0.984
Suzuki Kizashi Sedan 2012 9 9 0.967 1 0.995 0.942
Suzuki SX4 Hatchback 2012 8 8 0.984 0.875 0.892 0.838
Suzuki SX4 Sedan 2012 8 8 1 0.938 0.995 0.973
Tesla Model S Sedan 2012 8 8 0.97 1 0.995 0.995
Toyota Sequoia SUV 2012 8 8 0.969 1 0.995 0.975
Toyota Camry Sedan 2012 9 9 0.967 1 0.995 0.995
Toyota Corolla Sedan 2012 9 9 0.974 1 0.995 0.927
Toyota 4Runner SUV 2012 8 8 0.965 1 0.995 0.995
Volkswagen Golf Hatchback 2012 9 9 0.828 0.889 0.951 0.888
Volkswagen Golf Hatchback 1991 9 9 0.972 1 0.995 0.995
Volkswagen Beetle Hatchback 2012 9 9 0.967 1 0.995 0.971
Volvo C30 Hatchback 2012 8 8 0.932 1 0.995 0.907
Volvo 240 Sedan 1993 9 9 0.972 1 0.995 0.949
Volvo XC90 SUV 2007 9 9 1 0.941 0.995 0.995
smart fortwo Convertible 2012 8 8 0.971 1 0.995 0.963
Speed: 0.1ms preprocess, 4.5ms inference, 0.0ms loss, 0.6ms postprocess per image
Results saved to runs/detect/train
Training Metrics
print(f"Precision: {train_metrics.results_dict['metrics/precision(B)']:.4f}")
print(f"Recall: {train_metrics.results_dict['metrics/recall(B)']:.4f}")
print(f"mAP@0.5: {train_metrics.results_dict['metrics/mAP50(B)']:.4f}")
print(f"mAP@0.5:0.95: {train_metrics.results_dict['metrics/mAP50-95(B)']:.4f}")
print(f"fitness: {train_metrics.results_dict['fitness']:.4f}")
Precision: 0.9235 Recall: 0.9094 mAP@0.5: 0.9477 mAP@0.5:0.95: 0.9020 fitness: 0.9066
pd.DataFrame([train_metrics.results_dict]).to_csv("YOLO_train_metrics.csv", index=False)
Observation Of Training Model
*The model is highly accurate, well-generalized, and robust — ready for deployment.*
Using Validation Data
metrics = model.val()
Ultralytics 8.3.96 🚀 Python-3.10.16 torch-2.6.0+cu124 CUDA:0 (NVIDIA A10G, 22503MiB) Model summary (fused): 112 layers, 43,757,724 parameters, 0 gradients, 165.7 GFLOPs
val: Scanning /home/ec2-user/SageMaker/dataset/labels/val.cache... 1629 images, 0 backgrounds, 0 corrupt: 100%|██████████| 1629/1629 [00:00<?, ?it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 102/102 [00:17<00:00, 5.85it/s]
all 1629 1629 0.923 0.91 0.948 0.901
AM General Hummer SUV 2000 9 9 0.867 1 0.962 0.917
Acura RL Sedan 2012 6 6 0.938 0.833 0.922 0.922
Acura TL Sedan 2012 9 9 0.996 1 0.995 0.78
Acura TL Type-S 2008 8 8 0.973 1 0.995 0.995
Acura TSX Sedan 2012 8 8 0.874 1 0.982 0.925
Acura Integra Type R 2001 9 9 0.968 1 0.995 0.974
Acura ZDX Hatchback 2012 8 8 0.963 1 0.995 0.983
Aston Martin V8 Vantage Convertible 2012 9 9 0.857 0.664 0.829 0.782
Aston Martin V8 Vantage Coupe 2012 8 8 0.863 0.792 0.884 0.803
Aston Martin Virage Convertible 2012 6 6 0.817 0.833 0.793 0.728
Aston Martin Virage Coupe 2012 8 8 0.953 0.875 0.931 0.834
Audi RS 4 Convertible 2008 7 7 0.967 0.857 0.883 0.734
Audi A5 Coupe 2012 8 8 0.883 0.945 0.898 0.898
Audi TTS Coupe 2012 9 9 0.474 0.304 0.553 0.553
Audi R8 Coupe 2012 9 9 1 0.796 0.907 0.885
Audi V8 Sedan 1994 9 9 0.771 0.889 0.83 0.795
Audi 100 Sedan 1994 8 8 0.586 0.75 0.823 0.782
Audi 100 Wagon 1994 9 9 0.983 0.556 0.812 0.73
Audi TT Hatchback 2011 8 8 0.617 0.606 0.584 0.554
Audi S6 Sedan 2011 9 9 0.99 1 0.995 0.985
Audi S5 Convertible 2012 8 8 0.845 1 0.967 0.941
Audi S5 Coupe 2012 9 9 0.946 0.667 0.805 0.64
Audi S4 Sedan 2012 8 8 1 0.934 0.995 0.973
Audi S4 Sedan 2007 9 9 0.983 1 0.995 0.979
Audi TT RS Coupe 2012 8 8 0.936 0.875 0.982 0.951
BMW ActiveHybrid 5 Sedan 2012 7 7 0.95 1 0.995 0.963
BMW 1 Series Convertible 2012 7 7 0.754 1 0.806 0.789
BMW 1 Series Coupe 2012 8 8 1 0.783 0.995 0.792
BMW 3 Series Sedan 2012 9 9 0.868 0.732 0.941 0.916
BMW 3 Series Wagon 2012 8 8 0.961 0.75 0.923 0.815
BMW 6 Series Convertible 2007 9 9 0.964 1 0.995 0.897
BMW X5 SUV 2007 8 8 0.985 1 0.995 0.93
BMW X6 SUV 2012 8 8 0.989 1 0.995 0.984
BMW M3 Coupe 2012 9 9 1 0.936 0.995 0.995
BMW M5 Sedan 2010 8 8 0.885 1 0.954 0.942
BMW M6 Convertible 2010 8 8 0.978 1 0.995 0.984
BMW X3 SUV 2012 8 8 1 0.874 0.995 0.981
BMW Z4 Convertible 2012 8 8 1 0.917 0.995 0.922
Bentley Continental Supersports Conv. Convertible 2012 7 7 1 0.803 0.978 0.912
Bentley Arnage Sedan 2009 8 8 0.877 0.889 0.982 0.905
Bentley Mulsanne Sedan 2011 7 7 1 0.921 0.995 0.983
Bentley Continental GT Coupe 2012 7 7 0.936 0.714 0.933 0.911
Bentley Continental GT Coupe 2007 9 9 0.617 0.889 0.943 0.943
Bentley Continental Flying Spur Sedan 2007 9 9 1 0.812 0.995 0.995
Bugatti Veyron 16.4 Convertible 2009 6 6 0.611 0.833 0.663 0.63
Bugatti Veyron 16.4 Coupe 2009 9 9 1 0.869 0.995 0.94
Buick Regal GS 2012 7 7 0.961 1 0.995 0.984
Buick Rainier SUV 2007 9 9 0.981 0.889 0.917 0.917
Buick Verano Sedan 2012 7 7 0.974 1 0.995 0.995
Buick Enclave SUV 2012 8 8 0.963 1 0.995 0.964
Cadillac CTS-V Sedan 2012 9 9 0.973 1 0.995 0.814
Cadillac SRX SUV 2012 8 8 0.971 1 0.995 0.966
Cadillac Escalade EXT Crew Cab 2007 9 9 0.976 1 0.995 0.957
Chevrolet Silverado 1500 Hybrid Crew Cab 2012 8 8 0.961 0.625 0.928 0.894
Chevrolet Corvette Convertible 2012 8 8 0.867 1 0.995 0.929
Chevrolet Corvette ZR1 2012 9 9 0.965 0.889 0.975 0.902
Chevrolet Corvette Ron Fellows Edition Z06 2007 8 8 0.978 1 0.995 0.963
Chevrolet Traverse SUV 2012 9 9 0.981 1 0.995 0.929
Chevrolet Camaro Convertible 2012 9 9 1 0.923 0.995 0.963
Chevrolet HHR SS 2010 7 7 0.962 1 0.995 0.983
Chevrolet Impala Sedan 2007 9 9 0.968 1 0.995 0.906
Chevrolet Tahoe Hybrid SUV 2012 7 7 0.693 0.714 0.77 0.757
Chevrolet Sonic Sedan 2012 9 9 0.864 1 0.995 0.947
Chevrolet Express Cargo Van 2007 6 6 0.526 0.743 0.716 0.633
Chevrolet Avalanche Crew Cab 2012 9 9 0.881 0.826 0.962 0.953
Chevrolet Cobalt SS 2010 8 8 1 0.804 0.944 0.929
Chevrolet Malibu Hybrid Sedan 2010 8 8 0.983 1 0.995 0.977
Chevrolet TrailBlazer SS 2009 8 8 0.883 0.945 0.912 0.912
Chevrolet Silverado 2500HD Regular Cab 2012 7 7 0.639 0.571 0.633 0.615
Chevrolet Silverado 1500 Classic Extended Cab 2007 9 9 0.956 0.889 0.956 0.919
Chevrolet Express Van 2007 7 7 0.774 0.497 0.803 0.774
Chevrolet Monte Carlo Coupe 2007 9 9 1 0.847 0.9 0.885
Chevrolet Malibu Sedan 2007 9 9 0.902 1 0.995 0.974
Chevrolet Silverado 1500 Extended Cab 2012 9 9 0.609 0.889 0.772 0.748
Chevrolet Silverado 1500 Regular Cab 2012 9 9 0.745 0.778 0.84 0.799
Chrysler Aspen SUV 2009 9 9 0.951 1 0.995 0.932
Chrysler Sebring Convertible 2010 8 8 0.879 0.91 0.982 0.957
Chrysler Town and Country Minivan 2012 8 8 0.878 0.906 0.939 0.899
Chrysler 300 SRT-8 2010 10 10 0.883 1 0.995 0.931
Chrysler Crossfire Convertible 2008 9 9 0.969 1 0.995 0.943
Chrysler PT Cruiser Convertible 2008 9 9 0.97 1 0.995 0.936
Daewoo Nubira Wagon 2002 9 9 0.967 1 0.995 0.97
Dodge Caliber Wagon 2012 8 8 0.766 0.415 0.624 0.608
Dodge Caliber Wagon 2007 8 8 0.62 0.75 0.683 0.676
Dodge Caravan Minivan 1997 9 9 0.968 1 0.995 0.94
Dodge Ram Pickup 3500 Crew Cab 2010 9 9 0.865 1 0.929 0.877
Dodge Ram Pickup 3500 Quad Cab 2009 9 9 0.953 0.889 0.901 0.901
Dodge Sprinter Cargo Van 2009 8 8 0.863 0.789 0.865 0.745
Dodge Journey SUV 2012 9 9 0.872 1 0.895 0.88
Dodge Dakota Crew Cab 2010 8 8 0.779 0.881 0.955 0.931
Dodge Dakota Club Cab 2007 8 8 1 0.816 0.971 0.937
Dodge Magnum Wagon 2008 8 8 1 0.798 0.982 0.92
Dodge Challenger SRT8 2011 8 8 0.994 1 0.995 0.962
Dodge Durango SUV 2012 9 9 0.976 0.889 0.904 0.881
Dodge Durango SUV 2007 9 9 0.982 0.889 0.984 0.897
Dodge Charger Sedan 2012 8 8 0.878 1 0.995 0.995
Dodge Charger SRT-8 2009 8 8 0.865 0.803 0.892 0.87
Eagle Talon Hatchback 1998 9 9 0.967 1 0.995 0.903
FIAT 500 Abarth 2012 5 5 0.97 1 0.995 0.864
FIAT 500 Convertible 2012 7 7 0.96 1 0.995 0.977
Ferrari FF Coupe 2012 8 8 0.952 0.875 0.982 0.929
Ferrari California Convertible 2012 8 8 0.965 1 0.995 0.995
Ferrari 458 Italia Convertible 2012 8 8 0.874 1 0.912 0.828
Ferrari 458 Italia Coupe 2012 9 9 0.864 0.778 0.892 0.827
Fisker Karma Sedan 2012 9 9 0.972 1 0.995 0.98
Ford F-450 Super Duty Crew Cab 2012 8 8 1 0.813 0.995 0.964
Ford Mustang Convertible 2007 9 9 1 0.877 0.995 0.963
Ford Freestar Minivan 2007 9 9 0.974 1 0.995 0.966
Ford Expedition EL SUV 2009 9 9 0.976 1 0.995 0.957
Ford Edge SUV 2012 9 9 1 0.947 0.995 0.92
Ford Ranger SuperCab 2011 8 8 0.96 1 0.995 0.995
Ford GT Coupe 2006 9 9 0.887 0.889 0.932 0.908
Ford F-150 Regular Cab 2012 9 9 0.882 0.831 0.963 0.936
Ford F-150 Regular Cab 2007 9 9 0.887 0.877 0.951 0.938
Ford Focus Sedan 2007 9 9 0.961 1 0.995 0.975
Ford E-Series Wagon Van 2012 8 8 0.966 1 0.995 0.985
Ford Fiesta Sedan 2012 9 9 0.978 1 0.995 0.959
GMC Terrain SUV 2012 8 8 0.978 1 0.995 0.97
GMC Savana Van 2012 14 14 0.86 0.88 0.909 0.877
GMC Yukon Hybrid SUV 2012 9 9 0.901 0.889 0.984 0.972
GMC Acadia SUV 2012 9 9 1 0.947 0.995 0.935
GMC Canyon Extended Cab 2012 8 8 0.958 0.875 0.982 0.932
Geo Metro Convertible 1993 9 9 0.961 1 0.995 0.893
HUMMER H3T Crew Cab 2010 8 8 0.728 0.672 0.803 0.731
HUMMER H2 SUT Crew Cab 2009 9 9 0.847 0.556 0.805 0.769
Honda Odyssey Minivan 2012 8 8 0.965 1 0.995 0.972
Honda Odyssey Minivan 2007 8 8 0.969 1 0.995 0.974
Honda Accord Coupe 2012 8 8 0.97 0.875 0.896 0.884
Honda Accord Sedan 2012 8 8 0.962 1 0.995 0.957
Hyundai Veloster Hatchback 2012 8 8 0.976 1 0.995 0.921
Hyundai Santa Fe SUV 2012 8 8 0.97 1 0.995 0.851
Hyundai Tucson SUV 2012 9 9 0.964 1 0.995 0.966
Hyundai Veracruz SUV 2012 8 8 0.963 1 0.995 0.995
Hyundai Sonata Hybrid Sedan 2012 7 7 1 0.808 0.995 0.983
Hyundai Elantra Sedan 2007 8 8 0.949 0.875 0.892 0.871
Hyundai Accent Sedan 2012 5 5 0.97 1 0.995 0.961
Hyundai Genesis Sedan 2012 9 9 0.979 1 0.995 0.937
Hyundai Sonata Sedan 2012 8 8 0.876 0.885 0.967 0.897
Hyundai Elantra Touring Hatchback 2012 9 9 0.972 1 0.995 0.971
Hyundai Azera Sedan 2012 8 8 0.957 0.875 0.971 0.888
Infiniti G Coupe IPL 2012 7 7 0.972 1 0.995 0.944
Infiniti QX56 SUV 2011 6 6 0.957 1 0.995 0.976
Isuzu Ascender SUV 2008 8 8 0.954 0.75 0.967 0.882
Jaguar XK XKR 2012 9 9 1 0.92 0.995 0.877
Jeep Patriot SUV 2012 9 9 0.961 1 0.995 0.965
Jeep Wrangler SUV 2012 9 9 0.967 1 0.995 0.96
Jeep Liberty SUV 2012 9 9 0.956 0.889 0.984 0.955
Jeep Grand Cherokee SUV 2012 9 9 0.894 0.94 0.973 0.965
Jeep Compass SUV 2012 9 9 0.941 1 0.995 0.995
Lamborghini Reventon Coupe 2008 7 7 0.932 1 0.995 0.589
Lamborghini Aventador Coupe 2012 9 9 1 0.876 0.984 0.925
Lamborghini Gallardo LP 570-4 Superleggera 2012 7 7 0.958 1 0.995 0.943
Lamborghini Diablo Coupe 2001 9 9 0.898 0.889 0.984 0.628
Land Rover Range Rover SUV 2012 9 9 0.967 1 0.995 0.995
Land Rover LR2 SUV 2012 9 9 1 0.957 0.995 0.925
Lincoln Town Car Sedan 2011 8 8 0.932 1 0.995 0.942
MINI Cooper Roadster Convertible 2012 7 7 0.972 1 0.995 0.995
Maybach Landaulet Convertible 2012 6 6 1 0.427 0.972 0.849
Mazda Tribute SUV 2011 7 7 0.943 1 0.995 0.995
McLaren MP4-12C Coupe 2012 9 9 0.864 1 0.984 0.935
Mercedes-Benz 300-Class Convertible 1993 10 10 0.997 0.9 0.978 0.914
Mercedes-Benz C-Class Sedan 2012 9 9 1 0.854 0.984 0.849
Mercedes-Benz SL-Class Coupe 2009 7 7 0.956 1 0.995 0.905
Mercedes-Benz E-Class Sedan 2012 9 9 0.973 1 0.995 0.961
Mercedes-Benz S-Class Sedan 2012 9 9 0.966 1 0.995 0.942
Mercedes-Benz Sprinter Van 2012 8 8 0.835 0.875 0.817 0.741
Mitsubishi Lancer Sedan 2012 10 10 0.965 1 0.995 0.958
Nissan Leaf Hatchback 2012 8 8 0.871 1 0.912 0.88
Nissan NV Passenger Van 2012 8 8 1 0.972 0.995 0.942
Nissan Juke Hatchback 2012 9 9 0.966 1 0.995 0.944
Nissan 240SX Coupe 1998 9 9 0.971 1 0.995 0.95
Plymouth Neon Coupe 1999 9 9 0.967 0.889 0.915 0.905
Porsche Panamera Sedan 2012 9 9 1 0.947 0.995 0.976
Ram C-V Cargo Van Minivan 2012 8 8 0.961 0.875 0.888 0.767
Rolls-Royce Phantom Drophead Coupe Convertible 2012 6 6 0.956 1 0.995 0.965
Rolls-Royce Ghost Sedan 2012 8 8 0.805 0.75 0.777 0.772
Rolls-Royce Phantom Sedan 2012 9 9 0.764 0.722 0.766 0.669
Scion xD Hatchback 2012 8 8 0.971 1 0.995 0.956
Spyker C8 Convertible 2009 9 9 0.816 0.778 0.838 0.838
Spyker C8 Coupe 2009 9 9 0.791 0.889 0.818 0.78
Suzuki Aerio Sedan 2007 8 8 0.965 1 0.995 0.97
Suzuki Kizashi Sedan 2012 9 9 0.967 1 0.995 0.942
Suzuki SX4 Hatchback 2012 8 8 0.984 0.875 0.892 0.838
Suzuki SX4 Sedan 2012 8 8 1 0.94 0.995 0.973
Tesla Model S Sedan 2012 8 8 0.97 1 0.995 0.995
Toyota Sequoia SUV 2012 8 8 0.966 1 0.995 0.975
Toyota Camry Sedan 2012 9 9 0.966 1 0.995 0.995
Toyota Corolla Sedan 2012 9 9 0.967 1 0.995 0.927
Toyota 4Runner SUV 2012 8 8 0.964 1 0.995 0.995
Volkswagen Golf Hatchback 2012 9 9 0.809 0.946 0.975 0.91
Volkswagen Golf Hatchback 1991 9 9 0.972 1 0.995 0.995
Volkswagen Beetle Hatchback 2012 9 9 0.967 1 0.995 0.971
Volvo C30 Hatchback 2012 8 8 0.929 1 0.995 0.897
Volvo 240 Sedan 1993 9 9 0.972 1 0.995 0.952
Volvo XC90 SUV 2007 9 9 1 0.941 0.995 0.995
smart fortwo Convertible 2012 8 8 0.969 1 0.995 0.947
Speed: 0.1ms preprocess, 8.4ms inference, 0.0ms loss, 0.5ms postprocess per image
Results saved to runs/detect/train2
print(f"Precision: {metrics.results_dict['metrics/precision(B)']:.4f}")
print(f"Recall: {metrics.results_dict['metrics/recall(B)']:.4f}")
print(f"mAP@0.5: {metrics.results_dict['metrics/mAP50(B)']:.4f}")
print(f"mAP@0.5:0.95: {metrics.results_dict['metrics/mAP50-95(B)']:.4f}")
print(f"fitness: {metrics.results_dict['fitness']:.4f}")
Precision: 0.9228 Recall: 0.9096 mAP@0.5: 0.9475 mAP@0.5:0.95: 0.9013 fitness: 0.9059
Observation For Validation Metrics:
*The model shows high accuracy and strong generalization — it’s well-trained and deployment-ready.*
Graph Display
log_df = pd.read_csv("runs/detect/train/results.csv")
%matplotlib inline
log_df[["train/box_loss", "train/cls_loss", "val/box_loss", "val/cls_loss"]].plot(title="Loss Curves")
plt.xlabel("Epoch")
plt.ylabel("Loss")
plt.grid()
plt.show()
log_df[["metrics/mAP50(B)", "metrics/mAP50-95(B)"]].plot(title="mAP over Epochs")
plt.xlabel("Epoch")
plt.ylabel("mAP")
plt.grid()
plt.show()
log_df[["metrics/precision(B)", "metrics/recall(B)"]].plot(title="Precision and Recall over Epochs")
plt.xlabel("Epoch")
plt.ylabel("Score")
plt.grid()
plt.show()
Observation
results = model("dataset/images/val/00001.jpg")
results[0].show()
image 1/1 /home/ec2-user/SageMaker/dataset/images/val/00001.jpg: 448x640 1 Audi TT Hatchback 2011, 60.7ms Speed: 1.9ms preprocess, 60.7ms inference, 1.1ms postprocess per image at shape (1, 3, 448, 640)
results = model("dataset/images/val/00094.jpg")
results[0].show()
image 1/1 /home/ec2-user/SageMaker/dataset/images/val/00094.jpg: 416x640 1 Ford GT Coupe 2006, 60.8ms Speed: 1.4ms preprocess, 60.8ms inference, 1.0ms postprocess per image at shape (1, 3, 416, 640)
Observation
Predicting using the test data set
test_metrics = model.val(split='test', save=True, save_txt=True)
Ultralytics 8.3.96 🚀 Python-3.10.16 torch-2.6.0+cu124 CUDA:0 (NVIDIA A10G, 22503MiB)
val: Scanning /home/ec2-user/SageMaker/dataset/labels/test... 8041 images, 0 backgrounds, 0 corrupt: 100%|██████████| 8041/8041 [00:06<00:00, 1267.83it/s]
val: New cache created: /home/ec2-user/SageMaker/dataset/labels/test.cache
Class Images Instances Box(P R mAP50 mAP50-95): 100%|██████████| 503/503 [01:38<00:00, 5.08it/s]
all 8041 8041 0.932 0.91 0.949 0.899
AM General Hummer SUV 2000 44 44 0.922 0.977 0.976 0.93
Acura RL Sedan 2012 32 32 0.776 0.844 0.838 0.838
Acura TL Sedan 2012 43 43 0.809 0.885 0.935 0.826
Acura TL Type-S 2008 42 42 0.997 0.976 0.991 0.981
Acura TSX Sedan 2012 40 40 0.969 0.778 0.906 0.883
Acura Integra Type R 2001 44 44 0.896 0.98 0.982 0.962
Acura ZDX Hatchback 2012 39 39 0.991 0.897 0.918 0.892
Aston Martin V8 Vantage Convertible 2012 45 45 0.774 0.8 0.824 0.761
Aston Martin V8 Vantage Coupe 2012 41 41 0.919 0.826 0.915 0.855
Aston Martin Virage Convertible 2012 33 33 0.923 0.758 0.927 0.909
Aston Martin Virage Coupe 2012 38 38 0.92 0.914 0.93 0.879
Audi RS 4 Convertible 2008 36 36 1 0.943 0.968 0.765
Audi A5 Coupe 2012 41 41 0.676 0.902 0.86 0.848
Audi TTS Coupe 2012 42 42 0.581 0.562 0.622 0.573
Audi R8 Coupe 2012 43 43 0.951 0.907 0.972 0.946
Audi V8 Sedan 1994 43 43 0.86 0.712 0.834 0.781
Audi 100 Sedan 1994 40 40 0.744 0.85 0.784 0.752
Audi 100 Wagon 1994 42 42 0.938 0.721 0.898 0.741
Audi TT Hatchback 2011 40 40 0.496 0.475 0.548 0.524
Audi S6 Sedan 2011 46 46 0.953 0.957 0.974 0.939
Audi S5 Convertible 2012 42 42 0.902 0.875 0.906 0.859
Audi S5 Coupe 2012 42 42 0.791 0.541 0.741 0.656
Audi S4 Sedan 2012 39 39 0.966 0.735 0.952 0.922
Audi S4 Sedan 2007 45 45 0.992 0.978 0.99 0.974
Audi TT RS Coupe 2012 39 39 0.854 0.752 0.925 0.912
BMW ActiveHybrid 5 Sedan 2012 34 34 0.952 0.971 0.992 0.965
BMW 1 Series Convertible 2012 35 35 1 0.989 0.995 0.956
BMW 1 Series Coupe 2012 41 41 0.973 1 0.995 0.856
BMW 3 Series Sedan 2012 42 42 0.965 0.857 0.96 0.883
BMW 3 Series Wagon 2012 41 41 0.95 0.925 0.986 0.832
BMW 6 Series Convertible 2007 44 44 0.875 0.614 0.816 0.738
BMW X5 SUV 2007 41 41 0.987 0.951 0.993 0.896
BMW X6 SUV 2012 42 42 0.985 0.976 0.992 0.964
BMW M3 Coupe 2012 44 44 0.97 0.955 0.985 0.958
BMW M5 Sedan 2010 41 41 0.971 0.951 0.992 0.987
BMW M6 Convertible 2010 41 41 0.649 0.904 0.863 0.81
BMW X3 SUV 2012 38 38 0.99 0.974 0.99 0.973
BMW Z4 Convertible 2012 40 40 0.972 0.867 0.953 0.895
Bentley Continental Supersports Conv. Convertible 2012 36 36 0.94 0.874 0.941 0.902
Bentley Arnage Sedan 2009 39 39 0.974 0.961 0.991 0.964
Bentley Mulsanne Sedan 2011 35 35 1 0.843 0.983 0.954
Bentley Continental GT Coupe 2012 34 34 0.824 0.735 0.809 0.78
Bentley Continental GT Coupe 2007 46 46 0.739 0.739 0.796 0.755
Bentley Continental Flying Spur Sedan 2007 44 44 0.925 0.846 0.952 0.91
Bugatti Veyron 16.4 Convertible 2009 32 32 0.814 0.812 0.847 0.781
Bugatti Veyron 16.4 Coupe 2009 43 43 0.868 0.837 0.902 0.882
Buick Regal GS 2012 35 35 0.98 1 0.995 0.962
Buick Rainier SUV 2007 42 42 1 0.911 0.992 0.968
Buick Verano Sedan 2012 37 37 0.995 1 0.995 0.972
Buick Enclave SUV 2012 42 42 0.999 1 0.995 0.964
Cadillac CTS-V Sedan 2012 43 43 0.983 1 0.995 0.762
Cadillac SRX SUV 2012 41 41 0.995 1 0.995 0.929
Cadillac Escalade EXT Crew Cab 2007 44 44 0.919 0.977 0.97 0.838
Chevrolet Silverado 1500 Hybrid Crew Cab 2012 40 40 0.923 0.902 0.959 0.921
Chevrolet Corvette Convertible 2012 39 39 0.947 0.921 0.953 0.915
Chevrolet Corvette ZR1 2012 46 46 0.89 0.875 0.933 0.869
Chevrolet Corvette Ron Fellows Edition Z06 2007 37 37 0.917 0.898 0.969 0.88
Chevrolet Traverse SUV 2012 44 44 1 0.976 0.994 0.956
Chevrolet Camaro Convertible 2012 44 44 0.968 0.864 0.954 0.904
Chevrolet HHR SS 2010 36 36 0.995 1 0.995 0.948
Chevrolet Impala Sedan 2007 43 43 0.949 0.874 0.977 0.963
Chevrolet Tahoe Hybrid SUV 2012 37 37 0.835 0.683 0.845 0.823
Chevrolet Sonic Sedan 2012 44 44 0.948 1 0.988 0.883
Chevrolet Express Cargo Van 2007 29 29 0.582 0.69 0.632 0.603
Chevrolet Avalanche Crew Cab 2012 45 45 0.858 0.889 0.889 0.845
Chevrolet Cobalt SS 2010 41 41 0.992 0.976 0.979 0.909
Chevrolet Malibu Hybrid Sedan 2010 38 38 0.945 0.908 0.965 0.946
Chevrolet TrailBlazer SS 2009 40 40 0.987 0.975 0.992 0.974
Chevrolet Silverado 2500HD Regular Cab 2012 38 38 0.769 0.763 0.845 0.82
Chevrolet Silverado 1500 Classic Extended Cab 2007 42 42 0.909 0.956 0.983 0.946
Chevrolet Express Van 2007 35 35 0.639 0.507 0.634 0.61
Chevrolet Monte Carlo Coupe 2007 45 45 0.977 0.926 0.988 0.946
Chevrolet Malibu Sedan 2007 44 44 0.949 0.849 0.924 0.807
Chevrolet Silverado 1500 Extended Cab 2012 43 43 0.747 0.93 0.947 0.907
Chevrolet Silverado 1500 Regular Cab 2012 44 44 0.824 0.75 0.865 0.841
Chrysler Aspen SUV 2009 43 43 0.968 0.977 0.986 0.941
Chrysler Sebring Convertible 2010 40 40 0.967 0.95 0.96 0.92
Chrysler Town and Country Minivan 2012 37 37 0.883 0.973 0.984 0.919
Chrysler 300 SRT-8 2010 48 48 0.943 0.896 0.947 0.881
Chrysler Crossfire Convertible 2008 43 43 0.997 0.953 0.98 0.961
Chrysler PT Cruiser Convertible 2008 45 45 1 0.967 0.995 0.912
Daewoo Nubira Wagon 2002 45 45 0.998 0.933 0.992 0.96
Dodge Caliber Wagon 2012 40 40 0.781 0.713 0.74 0.718
Dodge Caliber Wagon 2007 42 42 0.723 0.809 0.793 0.762
Dodge Caravan Minivan 1997 43 43 0.992 1 0.995 0.981
Dodge Ram Pickup 3500 Crew Cab 2010 42 42 0.921 0.929 0.968 0.917
Dodge Ram Pickup 3500 Quad Cab 2009 44 44 0.911 0.927 0.935 0.898
Dodge Sprinter Cargo Van 2009 39 39 0.852 0.795 0.861 0.803
Dodge Journey SUV 2012 44 44 0.992 0.955 0.973 0.963
Dodge Dakota Crew Cab 2010 41 41 0.959 0.951 0.976 0.952
Dodge Dakota Club Cab 2007 38 38 0.952 0.974 0.994 0.972
Dodge Magnum Wagon 2008 40 40 0.963 0.925 0.975 0.921
Dodge Challenger SRT8 2011 39 39 1 0.974 0.994 0.987
Dodge Durango SUV 2012 43 43 0.993 1 0.995 0.988
Dodge Durango SUV 2007 45 45 1 0.964 0.978 0.872
Dodge Charger Sedan 2012 41 41 0.95 0.927 0.982 0.971
Dodge Charger SRT-8 2009 42 42 0.939 0.929 0.979 0.952
Eagle Talon Hatchback 1998 46 46 0.981 0.891 0.974 0.906
FIAT 500 Abarth 2012 27 27 0.989 1 0.995 0.762
FIAT 500 Convertible 2012 33 33 0.995 1 0.995 0.97
Ferrari FF Coupe 2012 42 42 1 0.98 0.995 0.966
Ferrari California Convertible 2012 39 39 1 0.995 0.995 0.981
Ferrari 458 Italia Convertible 2012 39 39 0.801 0.949 0.917 0.831
Ferrari 458 Italia Coupe 2012 42 42 0.973 0.85 0.976 0.934
Fisker Karma Sedan 2012 43 43 1 0.992 0.995 0.944
Ford F-450 Super Duty Crew Cab 2012 41 41 0.91 0.976 0.992 0.969
Ford Mustang Convertible 2007 44 44 1 0.99 0.995 0.92
Ford Freestar Minivan 2007 44 44 0.975 0.977 0.994 0.945
Ford Expedition EL SUV 2009 44 44 0.978 1 0.995 0.953
Ford Edge SUV 2012 43 43 0.969 0.977 0.992 0.903
Ford Ranger SuperCab 2011 42 42 0.976 0.974 0.994 0.977
Ford GT Coupe 2006 45 45 0.822 0.922 0.949 0.859
Ford F-150 Regular Cab 2012 42 42 0.972 1 0.995 0.97
Ford F-150 Regular Cab 2007 45 45 0.977 0.867 0.975 0.948
Ford Focus Sedan 2007 45 45 0.974 0.956 0.992 0.916
Ford E-Series Wagon Van 2012 37 37 0.999 1 0.995 0.92
Ford Fiesta Sedan 2012 42 42 0.971 1 0.994 0.958
GMC Terrain SUV 2012 41 41 0.952 0.967 0.963 0.891
GMC Savana Van 2012 68 68 0.836 0.902 0.922 0.86
GMC Yukon Hybrid SUV 2012 42 42 0.96 0.857 0.938 0.919
GMC Acadia SUV 2012 44 44 0.994 0.977 0.993 0.912
GMC Canyon Extended Cab 2012 40 40 0.948 0.911 0.982 0.95
Geo Metro Convertible 1993 44 44 0.976 0.923 0.988 0.844
HUMMER H3T Crew Cab 2010 39 39 0.884 0.872 0.938 0.88
HUMMER H2 SUT Crew Cab 2009 43 43 0.92 0.804 0.948 0.916
Honda Odyssey Minivan 2012 42 42 0.937 0.976 0.959 0.939
Honda Odyssey Minivan 2007 41 41 1 0.902 0.959 0.95
Honda Accord Coupe 2012 39 39 0.988 0.949 0.971 0.961
Honda Accord Sedan 2012 38 38 0.926 0.868 0.94 0.91
Hyundai Veloster Hatchback 2012 41 41 1 0.966 0.995 0.938
Hyundai Santa Fe SUV 2012 42 42 1 0.962 0.995 0.921
Hyundai Tucson SUV 2012 43 43 0.913 0.978 0.985 0.971
Hyundai Veracruz SUV 2012 42 42 0.931 0.881 0.937 0.908
Hyundai Sonata Hybrid Sedan 2012 33 33 1 0.877 0.965 0.929
Hyundai Elantra Sedan 2007 42 42 0.989 0.952 0.977 0.953
Hyundai Accent Sedan 2012 24 24 0.953 0.875 0.955 0.906
Hyundai Genesis Sedan 2012 43 43 1 0.981 0.995 0.964
Hyundai Sonata Sedan 2012 39 39 0.971 0.949 0.978 0.852
Hyundai Elantra Touring Hatchback 2012 42 42 0.98 0.952 0.994 0.96
Hyundai Azera Sedan 2012 42 42 0.889 0.881 0.904 0.852
Infiniti G Coupe IPL 2012 34 34 0.976 0.971 0.994 0.981
Infiniti QX56 SUV 2011 32 32 0.988 0.969 0.99 0.982
Isuzu Ascender SUV 2008 40 40 0.951 0.975 0.989 0.922
Jaguar XK XKR 2012 46 46 0.977 0.929 0.986 0.82
Jeep Patriot SUV 2012 44 44 0.927 0.977 0.992 0.973
Jeep Wrangler SUV 2012 43 43 1 0.999 0.995 0.944
Jeep Liberty SUV 2012 44 44 0.976 0.937 0.993 0.965
Jeep Grand Cherokee SUV 2012 45 45 0.932 0.921 0.915 0.868
Jeep Compass SUV 2012 42 42 0.905 0.881 0.924 0.911
Lamborghini Reventon Coupe 2008 36 36 0.887 0.944 0.899 0.613
Lamborghini Aventador Coupe 2012 43 43 0.953 0.977 0.978 0.865
Lamborghini Gallardo LP 570-4 Superleggera 2012 35 35 0.967 0.836 0.987 0.922
Lamborghini Diablo Coupe 2001 44 44 0.868 0.886 0.924 0.84
Land Rover Range Rover SUV 2012 42 42 0.966 1 0.985 0.981
Land Rover LR2 SUV 2012 42 42 1 0.924 0.987 0.968
Lincoln Town Car Sedan 2011 39 39 0.989 0.974 0.994 0.918
MINI Cooper Roadster Convertible 2012 36 36 0.971 0.972 0.978 0.929
Maybach Landaulet Convertible 2012 29 29 0.926 0.828 0.954 0.893
Mazda Tribute SUV 2011 36 36 0.981 0.972 0.994 0.981
McLaren MP4-12C Coupe 2012 44 44 0.964 0.977 0.991 0.969
Mercedes-Benz 300-Class Convertible 1993 48 48 0.967 0.979 0.993 0.877
Mercedes-Benz C-Class Sedan 2012 45 45 0.977 0.94 0.988 0.855
Mercedes-Benz SL-Class Coupe 2009 36 36 0.987 0.972 0.978 0.936
Mercedes-Benz E-Class Sedan 2012 43 43 0.977 0.996 0.995 0.959
Mercedes-Benz S-Class Sedan 2012 44 44 0.996 1 0.995 0.973
Mercedes-Benz Sprinter Van 2012 41 41 0.743 0.902 0.845 0.79
Mitsubishi Lancer Sedan 2012 47 47 0.97 0.915 0.969 0.923
Nissan Leaf Hatchback 2012 42 42 0.976 0.96 0.992 0.957
Nissan NV Passenger Van 2012 38 38 0.936 0.921 0.967 0.825
Nissan Juke Hatchback 2012 44 44 0.958 0.977 0.979 0.921
Nissan 240SX Coupe 1998 46 46 1 0.96 0.993 0.974
Plymouth Neon Coupe 1999 44 44 1 0.995 0.995 0.974
Porsche Panamera Sedan 2012 43 43 1 0.999 0.995 0.982
Ram C-V Cargo Van Minivan 2012 41 41 0.949 0.829 0.924 0.86
Rolls-Royce Phantom Drophead Coupe Convertible 2012 30 30 0.869 0.882 0.901 0.88
Rolls-Royce Ghost Sedan 2012 38 38 0.869 0.895 0.919 0.908
Rolls-Royce Phantom Sedan 2012 44 44 0.897 0.841 0.918 0.774
Scion xD Hatchback 2012 41 41 0.981 0.976 0.995 0.964
Spyker C8 Convertible 2009 45 45 0.873 0.956 0.906 0.857
Spyker C8 Coupe 2009 42 42 0.944 0.8 0.926 0.876
Suzuki Aerio Sedan 2007 38 38 0.946 0.816 0.938 0.913
Suzuki Kizashi Sedan 2012 46 46 1 0.952 0.985 0.939
Suzuki SX4 Hatchback 2012 42 42 0.969 0.976 0.993 0.971
Suzuki SX4 Sedan 2012 40 40 0.903 0.697 0.889 0.865
Tesla Model S Sedan 2012 38 38 1 1 0.995 0.881
Toyota Sequoia SUV 2012 38 38 0.989 0.947 0.977 0.947
Toyota Camry Sedan 2012 43 43 0.945 0.93 0.95 0.947
Toyota Corolla Sedan 2012 43 43 0.947 0.838 0.964 0.866
Toyota 4Runner SUV 2012 40 40 0.94 1 0.981 0.928
Volkswagen Golf Hatchback 2012 43 43 0.983 0.86 0.972 0.924
Volkswagen Golf Hatchback 1991 46 46 0.926 1 0.99 0.969
Volkswagen Beetle Hatchback 2012 42 42 0.99 0.976 0.979 0.96
Volvo C30 Hatchback 2012 41 41 0.974 0.914 0.978 0.928
Volvo 240 Sedan 1993 45 45 0.995 0.933 0.978 0.939
Volvo XC90 SUV 2007 43 43 0.999 0.977 0.994 0.973
smart fortwo Convertible 2012 40 40 0.992 1 0.995 0.938
Speed: 0.1ms preprocess, 8.3ms inference, 0.0ms loss, 0.5ms postprocess per image
Results saved to runs/detect/train3
print(f"Precision: {test_metrics.results_dict['metrics/precision(B)']:.4f}")
print(f"Recall: {test_metrics.results_dict['metrics/recall(B)']:.4f}")
print(f"mAP@0.5: {test_metrics.results_dict['metrics/mAP50(B)']:.4f}")
print(f"mAP@0.5:0.95: {test_metrics.results_dict['metrics/mAP50-95(B)']:.4f}")
print(f"fitness: {test_metrics.results_dict['fitness']:.4f}")
Precision: 0.9322 Recall: 0.9100 mAP@0.5: 0.9492 mAP@0.5:0.95: 0.8986 fitness: 0.9037
Observation
*The model is highly accurate and well-balanced in the test data set.*
results = model("dataset/images/test/05766.jpg")
image 1/1 /home/ec2-user/SageMaker/dataset/images/test/05766.jpg: 480x640 1 Bentley Continental GT Coupe 2007, 61.9ms Speed: 1.7ms preprocess, 61.9ms inference, 1.0ms postprocess per image at shape (1, 3, 480, 640)
results[0].show()
results = model("dataset/images/test/00008.jpg")
image 1/1 /home/ec2-user/SageMaker/dataset/images/test/00008.jpg: 416x640 1 Mercedes-Benz S-Class Sedan 2012, 9.4ms Speed: 1.2ms preprocess, 9.4ms inference, 1.0ms postprocess per image at shape (1, 3, 416, 640)
results[0].show()
Observation
Prediction For Untrained Images
results = model("DodgeCaliber2025.jpg")
image 1/1 /home/ec2-user/SageMaker/DodgeCaliber2025.jpg: 384x640 1 Dodge Caliber Wagon 2007, 62.1ms Speed: 1.2ms preprocess, 62.1ms inference, 1.0ms postprocess per image at shape (1, 3, 384, 640)
results[0].show()
Observation
results = model("fordmustang2025.jpg")
image 1/1 /home/ec2-user/SageMaker/fordmustang2025.jpg: 384x640 1 Ferrari 458 Italia Coupe 2012, 9.2ms Speed: 1.2ms preprocess, 9.2ms inference, 1.0ms postprocess per image at shape (1, 3, 384, 640)
results[0].show()
Observation
Conclusion
Test Metrics
pd.DataFrame([test_metrics.results_dict]).to_csv("test_metrics.csv", index=False)
df = pd.read_csv("test_metrics.csv")
print(df.T) # Transpose for easier viewing
0 metrics/precision(B) 0.932217 metrics/recall(B) 0.910020 metrics/mAP50(B) 0.949185 metrics/mAP50-95(B) 0.898625 fitness 0.903681
Saving the trained Model later use
best_model = YOLO("runs/detect/train/weights/best.pt")
os.makedirs("my_models", exist_ok=True)
best_model.save("my_models/yolo_car_detector_best.pt")
Observation